/**
 * Copyright (c) 2011-2015 1lifes.com
 * HSJ java-handlersocket
 * Id: PacketFactory.java
 */
package com.elifes.hsj.packet;

import java.util.List;

import com.elifes.hsj.model.CompareOperator;
import com.elifes.hsj.model.Filter;
import com.elifes.hsj.model.INFilter;
import com.elifes.hsj.model.Modify;

/**
 * 描述：
 * @author yangqiang
 * @createtime 2011-11-12下午5:59:45
 *
 */
public class PacketFactory {
	private static PacketFactory self = new PacketFactory();
	
	public static PacketFactory getInstance(){
		return self;
	}
	
	public IPacket createAuthPacket(String authKey){
		IPacket authPacket = new AuthPacket(authKey);
		return authPacket;
	}
	
	public IPacket createOpenIndexPacket(String indexId, String dbName,
			String tblName, String indexName, List<String> columnNames, List<String> filterColumnNames) {
		IPacket openIndexPacket = new OpenIndexPacket(indexId, dbName, tblName,
				indexName, columnNames, filterColumnNames);
		return openIndexPacket;
	}
	
	public IPacket createInsertPacket(String indexId, List<String> values){
		IPacket insertPacket = new InsertPacket(indexId, values);
		return insertPacket;
	}
	
	public IPacket createFindPacket(String indexId, CompareOperator operator,
			List<String> filterValues, int limit, int offset,
			INFilter in, List<Filter> filters, Class doClass, List<String> properties){
		IPacket findPacket = new FindPacket(indexId, operator, filterValues, limit, offset, in, filters, doClass, properties);
		return findPacket;
	}
	
	public IPacket createModifyPacket(String indexId, CompareOperator operator,
			List<String> filterValues, int limit, int offset,
			INFilter in, List<Filter> filters, Class doClass, List<String> properties, Modify mod){
		FindPacket findPacket = new FindPacket(indexId, operator, filterValues, limit, offset, in, filters, doClass, properties);
		
		IPacket modifyPacket = new ModifyPacket(findPacket, mod);
		return modifyPacket;
	}
}
